package top.drinyeit.nongmao.adapter;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

import top.drinyeit.nongmao.R;
import top.drinyeit.nongmao.interfaces.OnItemClickListener;
import top.drinyeit.nongmao.model.CategoryGoodsDetailsBean;

/**
 * Created by wu on 2018/1/9.
 */

public class ShopBottomGoodsAdapter extends RecyclerView.Adapter<ShopBottomGoodsAdapter.ViewHolder> {
    private Context context;
    private List<CategoryGoodsDetailsBean> list;
    private Activity activity;

    public ShopBottomGoodsAdapter(Activity activity, List<CategoryGoodsDetailsBean> list) {
        this.list = list;
        this.activity = activity;
    }
    OnItemClickListener onItemClickListener;

    public void setOnRvItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    @Override
    public ShopBottomGoodsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();
        View v = LayoutInflater.from(context).inflate(R.layout.item_shop_bottom_goods, parent, false);
        ViewHolder viewHolder = new ViewHolder(v);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ShopBottomGoodsAdapter.ViewHolder holder, int position) {
//        Glide.with(context).load(list.get(position).getCover_img_url())
//                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
//                .dontTransform()
//                .placeholder(R.drawable.ic_def)
//                .into(holder.iv_home_classfy_icon);

    }

    @Override
    public int getItemCount() {
        return list == null ? 10 : /*list.size()*/10;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        public ImageView iv_item_shop_center_classfy_top_left;
//        public TextView tv_item_home_classfy_price, tv_item_home_classfy_name;

        public ViewHolder(View itemView) {
            super(itemView);
            iv_item_shop_center_classfy_top_left = itemView.findViewById(R.id.iv_item_shop_center_classfy_top_left);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    onItemClickListener.onItemClick(view, getAdapterPosition());
                }
            });
//            tv_item_home_classfy_price = itemView.findViewById(R.id.tv_item_home_classfy_price);
//            tv_item_home_classfy_name = itemView.findViewById(R.id.tv_item_home_classfy_name);
        }


    }
}

